home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 5.0 KB | 193 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: PRBitmap.h
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef PRBITMAP_H
- #define PRBITMAP_H
-
- #ifndef FWSTDDEF_H
- #include "FWStdDef.h"
- #endif
-
- #ifndef SLGRDEF_H
- #include "SLGrDef.h"
- #endif
-
- #ifndef SLPTRECT_H
- #include "SLPtRect.h"
- #endif
-
- #ifndef PRGRREF_H
- #include "PRGrRef.h"
- #endif
-
- #ifndef SLPALETE_H
- #include "SLPalete.h"
- #endif
-
- #ifndef SLPICTUR_H
- #include "SLPictur.h"
- #endif
-
- //========================================================================================
- // Forward Declarations
- //========================================================================================
-
- class FW_OResourceFile;
-
- class FW_CReadableStream;
- class FW_CWritableStream;
-
- class FW_CColor;
-
- struct FW_SGraphicContext;
-
- //========================================================================================
- // class FW_CPrivBitmapRep
- //========================================================================================
-
- class FW_CPrivBitmapRep : public FW_CPrivGrRefObj
- {
- public:
- FW_DECLARE_AUTO(FW_CPrivBitmapRep)
-
- // ----- Construction -----
- FW_CPrivBitmapRep(
- short width, short height,
- short pixelSize, FW_Palette palette,
- void* image, long imageSize, short rowBytes);
-
- FW_CPrivBitmapRep(FW_PlatformBitmap platformBitmap);
-
- FW_CPrivBitmapRep(FW_OResourceFile* resourceFile, FW_ResourceID resID);
-
- FW_CPrivBitmapRep(const FW_CPrivBitmapRep& bitmap, const FW_SRect& srcRect);
-
- ~FW_CPrivBitmapRep();
-
- // ----- Common operations -----
- FW_Boolean IsEqual(const FW_CPrivBitmapRep& bitmap) const;
-
- // ----- Streaming -----
-
- void Write(FW_CWritableStream& stream, FW_Boolean bDIBFileHeader);
- FW_CPrivBitmapRep(FW_CReadableStream& stream, FW_Boolean bDIBFileHeader);
-
- // ----- Handle operations -----
-
- FW_PlatformBitmap GetPlatformBitmap() const;
- FW_Boolean IsPlatformBitmapOrphan() const;
- FW_PlatformBitmap OrphanPlatformBitmap();
-
- void SetPlatformBitmap(FW_PlatformBitmap newBitmap);
- void AdoptPlatformBitmap(FW_PlatformBitmap newBitmap);
-
- // ----- Palette -----
-
- FW_Palette GetPalette() const;
- void SetPalette(FW_Palette palette);
-
- // ----- Bitmap info -----
-
- void GetBitmapInfo(short& width, short& height,
- short& rowBytes, short& pixelSize) const;
-
- void GetBitmapBoundsGC(Environment* ev, FW_SGraphicContext& gc, FW_SRect& bounds) const;
- void GetBitmapBounds(FW_SRect& bounds) const;
-
- // ----- Pixel Manipulations -----
-
- void GetPixelColor(short horiz, short vert, FW_CColor& color) const;
- void SetPixelColor(short horiz, short vert, const FW_CColor& newColor);
-
- // ----- Changing the bitmap -----
-
- FW_PlatformError ChangeBitmap(short width,
- short height,
- short pixelSize,
- FW_Boolean bScale);
- FW_PlatformError ChangeBitmap(void* image,
- long imageSize,
- short rowBytes,
- short width,
- short height,
- short pixelSize,
- FW_Boolean bScale);
- FW_PlatformError SetImage(void* image, long imageSize, short rowBytes);
-
- // ----- Copy Pixels -----
-
- FW_PlatformError CopyPixels(FW_CPrivBitmapRep& dstBitmap,
- const FW_SRect& boundsSrc,
- const FW_SRect& boundsDst) const;
-
- #ifdef FW_BUILD_MAC
-
- // ----- Conversion -----
-
- FW_CPrivBitmapRep(FW_HPicture picture,
- FW_SColor fillColor, const FW_SRect& pictPart);
-
- FW_HPicture MacGetAsPicture(const FW_SRect& bounds) const;
- #endif
-
- // ----- Mac Lock/Unlock -----
- #ifdef FW_BUILD_MAC
- PixMapHandle MacLockPixels();
- void MacUnlockPixels();
- FW_Boolean MacIsPixelsLocked() const;
- #endif
-
- // ----- Implementation
- private:
- void PrivDisposeBitmap();
- void PrivMakeBitmap(short width, short height,
- short pixelSize, FW_Palette palette);
- void PrivReadFromStream(FW_CReadableStream& stream, FW_Boolean bDIBFileHeader);
-
- FW_Boolean fOwnBitmap;
- FW_PlatformBitmap fPlatformBitmap;
-
- #ifdef FW_BUILD_MAC
- short fLockCount;
- PixMapHandle fPixMapHandle;
- #endif
- #ifdef FW_BUILD_WIN
- // Windows GDI can only work with DDBs of two color depths: monochrome and whatever the
- // current display setting is. But the user can ask for an aribtrary color depth!
- // To solve this, I have to remember the requested color depth and use what GDI can do
- short fUserColorDepth;
- FW_Palette fWinPalette;
- #endif
- };
-
- #ifdef FW_BUILD_MAC
-
- //========================================================================================
- // CLASS FW_CPrivMacPixelLock
- //========================================================================================
-
- class FW_CPrivMacPixelLock
- {
- public:
- FW_DECLARE_AUTO(FW_CPrivMacPixelLock)
-
- FW_CPrivMacPixelLock(FW_HBitmap);
- ~FW_CPrivMacPixelLock();
-
- PixMapHandle GetPixMapHandle() const;
-
- private:
- FW_HBitmap fBitmap;
- PixMapHandle fPixMapHandle;
- };
-
- #endif
-
- #endif // PRBITMAP_H
-